import request from '../utils/request';

export async function queryList(data) {
  const params = data;
  sessionStorage.setItem('domainName', params.AppServerHost);
  return request(
    encodeURI(
      `/api/OALogin/request.do?URLparam=http://${params.AppServerHost}/${
        params.userAppName
      }/persontasks.nsf/vwgwdbshow_gwydoaH5?readviewentries@RestrictToCategory=${
        params.username
      }&type=db`,
    ),
    {
      method: 'GET',
    },
  );
}

//待阅
export async function queryDyList (data) {
  const params = data;
  sessionStorage.setItem('domainName',params.AppServerHost);
  return request(
    encodeURI(
      `/api/OALogin/request.do?URLparam=http://${params.AppServerHost }/${
      params.userAppName 
    }/persontasks.nsf/vwgwdyshowydoaH5?readviewentries@RestrictToCategory=${
      params.username 
    }&type=dy`,
  ),
    {
    method: 'GET',
  },
  );
}

//已办
export async function yibanList (params) {
  return request('/api/OALogin/request.do?URLparam=http://jtzb.cecic.corp/jtzb/persontasks.nsf/vwgwdbshow_gwydoaH5?readviewentries@RestrictToCategory=CN=孟维强/o=cecic&type=yb',{
    method: 'GET'
  })
}

//已阅
export async function readList (params) {
  return request('/api/OALogin/request.do?URLparam=http://jtzb.cecic.corp/jtzb/persontasks.nsf/vwgwyyshowydoaH5?readviewentries@RestrictToCategory=CN=孟维强/o=cecic&type=yy',{
    method: 'GET'
  })
}

export async function queryFormDetail(param) {
	 
  return request(
    `/api/OaWeb/formDetail.do?serverName=${param.serverName}&dbPath=${param.dbPath}&docUnid=${
      param.id
    }&domainName=${sessionStorage.getItem('domainName')}`,
    {
      method: 'GET',
    },
  );
}
export async function queryformHisInfo(param) {
  return request(
    `/api/OaWeb/formHisInfo.do?serverName=${param.serverName}&dbPath=${param.dbPath}&docUnid=${
      param.id
    }&&domainName=${sessionStorage.getItem('domainName')}`,
    {
      method: 'GET',
    },
  );
}

export async function queryformCyHisInfo(param) {
  return request(
    `/api/OaWeb/formCyHisInfo.do?serverName=${param.serverName}&dbPath=${param.dbPath}&docUnid=${
      param.id
    }&domainName=${sessionStorage.getItem('domainName')}`,
    {
      method: 'GET',
    },
  );
}

export async function queryformFlowHisInfo(param) {
  return request(
    `/api/OaWeb/formFlowHisInfo.do?serverName=${param.serverName}&dbPath=${param.dbPath}&docUnid=${
      param.id
    }&domainName=${sessionStorage.getItem('domainName')}`,
    {
      method: 'GET',
    },
  );
}
export async function queryformDocInfo(param) {
  return request(
    `/api/OaWeb/formDocInfo.do?serverName=${param.serverName}&dbPath=${param.dbPath}&docUnid=${
      param.id
    }&domainName=${sessionStorage.getItem('domainName')}`,
    {
      method: 'GET',
    },
  );
}
// 获取环节流程(办理页面)
export async function queryflowForName(param) {
  return request(
    `/api/OaSub/flowForName.do?requestId=${param.requestId}&unid=${param.unid}&dbPath=${
      param.dbPath
    }&userCode=${param.userCode}&opin=${
      param.opin
    }&domainName=${sessionStorage.getItem('domainName')}`,
    {
      method: 'GET',
    },
  );
}
// 获取环节默认办理人(办理页面)
export async function queryflowPerson(param) {
  return request(
    `/api/OaSub/flowPerson.do?requestId=${param.requestId}&unid=${param.unid}&dbPath=${
      param.dbPath
    }&curuser=${param.curuser}&extension=${param.extension}&opin=${
      param.opin
    }&domainName=${sessionStorage.getItem('domainName')}`,
    {
      method: 'GET',
    },
  );
}
// 验证环节
export async function validateFlow(param) {
  return request(`/api/OaSub/flowValidateInfo.do?requestId=${param.requestId}&unid=${
    param.unid
  }&dbPath=${param.dbPath}&curuser=${param.curuser}&extension=${param.extension}&opin=${
    param.opin
  }&domainName=${sessionStorage.getItem('domainName')}
  `);
}
// 提交
export async function submit(param) {
  return request(`/api/OaSub/flowSubmit.do?requestId=${param.requestId}&unid=${param.unid}&dbPath=${
    param.dbPath
  }&curuser=${param.curuser}&extension=${param.extension}&opin=${param.opin}&nextUser=${
    param.nextUser
  }&flowNum=${param.flowNum}&domainName=${sessionStorage.getItem('domainName')}
  `);
}
// 通讯录
export async function queryContacts(param) {
  return request(
    `/api/OaSub/getTreeInfo.do?deptCode=${param.code}&domainName=${sessionStorage.getItem(
      'domainName',
    )}`,
  );
}

// 通讯录
export async function initTicket(param) {
	//alert(JSON.stringify(param))
  return request(`/api/OALogin/ticketTerm.do?ticket=${param.ticket}&clientIp=${param.ip}`, {
    method: 'GET',
  });
}

// 通讯录
export async function validatePerInfo(param) {
  return request(`/api/OALogin/validatePerInfo.do?personunid=${param.id}`);
}
